package com.kamistoat.meimeimall.meimeimallpayment.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.Exchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

@Configuration
public class InitPaymentMQConfig {

    /**
     * 开始对账任务队列
     */
    @Bean
    public Queue reconciliationTaskStartQueue() {
        Queue reconciliationTaskStartQueue = new Queue(
                "reconciliation.task.start.queue",
                true,
                false,
                false);
        return reconciliationTaskStartQueue;
    }

    /**
     * payment服务的主交换机
     */
    @Bean
    public Exchange paymentEventExchange() {
        TopicExchange paymentEventExchange = new TopicExchange(
                "payment-event-exchange",
                true,
                false,
                null);
        return paymentEventExchange;
    }

    /**
     * 主交换机与开始队列的绑定规则
     */
    @Bean
    public Binding reconciliationTaskStartBinding() {
        Binding reconciliationTaskStartBinding = new Binding(
                "reconciliation.task.start.queue",
                Binding.DestinationType.QUEUE,
                "payment-event-exchange",
                "reconciliation.task.start",
                null);
        return reconciliationTaskStartBinding;
    }
}
